﻿using System;
using CDOP.Model;

namespace CDOP.UserControls
{
    public partial class UcOtherAgencies : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void AddObjectValues(ref MasterTable recordToFill)
        {
            recordToFill.Primary_Health_Care = chkPrimaryHealthCare.Checked;
            recordToFill.Secondary_Tertiary_Hospital_Services = chkSecondaryTertiaryHospitalServices.Checked;
            recordToFill.Secondary_Tertiary_Community_Health_Services = chkSecondaryTertiaryCommunityHealth.Checked;
            recordToFill.Hospice = chkHospice.Checked;
            recordToFill.CAHMS = chkCahms.Checked;
            recordToFill.Police = chkPolice.Checked;
            recordToFill.LACS = chkLacs.Checked;
            recordToFill.Education = chkEducation.Checked;
            recordToFill.Connexions = chkConnexions.Checked;
            recordToFill.Probation = chkProbation.Checked;
            recordToFill.YOT = chkYot.Checked;
            recordToFill.Others_1 = txtOthers1.Text;
            recordToFill.Others_2 = txtOthers2.Text;
            recordToFill.School_Nursery_College = txtSchoolNurseryCollege.Text;
            recordToFill.Protection_Plan = ddProtectionPlan.SelectedItem.Text;
            recordToFill.Statutory_Order = ddStatutoryOrder.SelectedItem.Text;
            recordToFill.Domestic_Violence = ddDomesticViolence.SelectedItem.Text;
        }

        public void LoadObjectValues(ref MasterTable recordToFill)
        {
            chkPrimaryHealthCare.Checked = recordToFill.Primary_Health_Care;
            chkSecondaryTertiaryHospitalServices.Checked = recordToFill.Secondary_Tertiary_Hospital_Services;
            chkSecondaryTertiaryCommunityHealth.Checked = recordToFill.Secondary_Tertiary_Community_Health_Services;
            chkHospice.Checked = recordToFill.Hospice;
            chkCahms.Checked = recordToFill.CAHMS;
            chkPolice.Checked = recordToFill.Police;
            chkLacs.Checked = recordToFill.LACS;
            chkEducation.Checked = recordToFill.Education;
            chkConnexions.Checked = recordToFill.Connexions;
            chkProbation.Checked = recordToFill.Probation;
            chkYot.Checked = recordToFill.YOT;
            txtOthers1.Text = recordToFill.Others_1;
            txtOthers2.Text = recordToFill.Others_2;
            txtSchoolNurseryCollege.Text = recordToFill.School_Nursery_College;
            if (ddProtectionPlan.Items.Count == 0)
                ddProtectionPlan.DataBind();
            ddProtectionPlan.SelectedIndex = ddProtectionPlan.Items.IndexOf(ddProtectionPlan.Items.FindByText(recordToFill.Protection_Plan));
            if (ddStatutoryOrder.Items.Count == 0)
                ddStatutoryOrder.DataBind();
            ddStatutoryOrder.SelectedIndex = ddStatutoryOrder.Items.IndexOf(ddStatutoryOrder.Items.FindByText(recordToFill.Statutory_Order));
            if (ddDomesticViolence.Items.Count == 0)
                ddDomesticViolence.DataBind();
            ddDomesticViolence.SelectedIndex = ddDomesticViolence.Items.IndexOf(ddDomesticViolence.Items.FindByText(recordToFill.Domestic_Violence));
        }
    }
}